package cn.edu.nwpu.manager.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
/**
 * @author Hutengzhong
 * @version 1.0.0
 * @title ClassManager 班级表
 * @description TODO
 * @date 2023/9/16
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ClassManager {

    private Integer id;
    private LocalDate beginDate;
    private String className;
    private Integer isDeleted;

    public ClassManager(HashMap parameters) {
        if (parameters == null) {
            return;
        } else {
            try {
                // parameters={beginDate=2023-2-27, className=一班}
                if (parameters.containsKey("id")) {
                    id = Integer.parseInt((String) parameters.get("id"));
                }
                if (parameters.containsKey("beginDate")) {
                    beginDate = LocalDate.parse((String) parameters.get("beginDate"), DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                }
                if (parameters.containsKey("className")) {
                    className = (String) parameters.get("className");
                }
            } catch (Exception e) {
                System.out.println("前端传递参数转化异常: 参考类型异常");
            }
        }
    }
}
